package com.serialstamper.api.wrapper.model;

import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * User model
 * @author mpolo@safecreative.org
 */
public class User implements Serializable {
	private String id;
	private String name;
	private String password;
	private String fullName;
	private String mail;
	private Date entryDate;
	private Map<String, String> metadata = new LinkedHashMap<String, String>();

	public User() {
	}
	
	public User(String name, String password) {
		this(name,password,null,null);
	}

	public User(String name, String password, String fullName, String mail) {
		this.name = name;
		this.password = password;
		this.fullName = fullName;
		this.mail = mail;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the fullName
	 */
	public String getFullName() {
		return fullName;
	}

	/**
	 * @param fullName the fullName to set
	 */
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	/**
	 * @return the mail
	 */
	public String getMail() {
		return mail;
	}

	/**
	 * @param mail the mail to set
	 */
	public void setMail(String mail) {
		this.mail = mail;
	}

	/**
	 * @return the entryDate
	 */
	public Date getEntryDate() {
		return entryDate;
	}

	/**
	 * @param entryDate the entryDate to set
	 */
	public void setEntryDate(Date entryDate) {
		this.entryDate = entryDate;
	}

	/**
	 * @return the metadata
	 */
	public Map<String, String> getMetadata() {
		return metadata;
	}

	/**
	 * @param metadata the metadata to set
	 */
	public void setMetadata(Map<String, String> metadata) {
		this.metadata = metadata;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj != null && obj instanceof User) {
			User other = (User)obj;
			if(this.id == null) {
				if(this.name != null && this.name.equals(other.name)) {
					if(this.fullName != null && !this.fullName.equals(other.fullName)) {
						return false;
					}
					if(this.mail != null && !this.mail.equals(other.mail)) {
						return false;
					}
					return true;
				}
				return false;	
			}
			return this.id.equals(other.id);
		}
		return false;
	}
	
	

	@Override
	public String toString() {
		return "User[name:"+name+",fullName:"+fullName+",mail:"+mail+"]";
	}	
	
}